package com.zkt.recommend.domain.utils;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * @author 赵开泰
 * @program jc-club
 * @date 2025/3/29
 * @description 时间相关工具类
 **/

public class DateUtil {
	
	/**
	 * 计算遗忘曲线影响权重
	 */
	public static double calculateForgettingWeight(LocalDateTime lastPracticeTime) {
		if (lastPracticeTime == null) {
			// 未练习过的题目权重最大
			return 1.0;
		}
		long hoursSinceLastPractice = Duration.between(lastPracticeTime, LocalDateTime.now()).toHours();
		
		// 指数衰减
		return Math.exp(-0.1 * hoursSinceLastPractice);
	}
	
}